﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewPageAutoRefresh.aspx.cs" Inherits="Easy.Web.Pages.DataPages.View.ViewPageAutoRefresh" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>视图</title>

    <script type="text/javascript" src="/_js/jquery-1.9.1.min.js" charset="UTF-8"></script>
    <script type="text/javascript" src="/_js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/_js/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
    <script src="/_js/common.js"></script>
    <script src="/_js/Core.js"></script>
    <script src="/_js/Core.View.js"></script>
    <script src="/_js/Core.Lookup.js" type="text/javascript"></script>
    <asp:Literal runat="server" ID="CoreScript"></asp:Literal>
    <script type="text/javascript" src="/Service/Data/JsHub.ashx?itemtype=view&entityname=<%=EntityName %>&itemname=<%=ViewName %>"></script>
    <link href="/_css/bootstrap.min.css" rel="stylesheet" />
    <link href="/_css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="/_css/sort.css" rel="stylesheet" type="text/css" />
    <link href="/_css/common.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/_css/iconfont.css" />

    <style>
        .datetimepicker {
            box-sizing: content-box;
        }

            .datetimepicker * {
                box-sizing: content-box;
            }

        .header {
            margin: 10px 0 10px 15px;
            font-size: 0;
        }

            .header > span {
                margin-right: 5px;
            }

        .dropdown {
            cursor: pointer;
        }

        .form-group {
            margin: 0;
            padding: 10px;
        }

        .dropdown-menu {
            -webkit-border-radius: 0;
        }

        .button-panel {
            padding: 0 10px 10px 10px;
        }

        .rebtn {
            margin-right: 3px;
        }

        #ListContainer {
            margin-bottom: 15px;
            border: 1px solid #e1e6eb;
        }

        #ListContainer, #ListContainer-title, #ListContainer-body {
            padding: 0;
        }

            #ListContainer-title .table, #ListContainer-body .table {
                margin: 0;
                border: none;
            }

            #ListContainer-body .table {
                border-top: 1px solid #e1e6eb;
            }

                #ListContainer-title .table thead tr th, #ListContainer-body .table thead tr td {
                    border: none;
                }

        #ListContainer-title {
            position: relative;
            z-index: 1;
        }

        #ListContainer-body {
            position: relative;
        }

        @media screen and (max-width: 767px) {
            .table-responsive {
                margin-bottom: 0;
                overflow: auto;
            }
        }

        #LookupListContainer {
            height: 420px;
            width: 558px;
            overflow: auto;
            margin-top: 8px;
            border: 1px solid #e1e6eb;
        }

        #LookupListContainer-title {
            position: relative;
            z-index: 1;
        }

        #LookupListContainer-body {
            position: relative;
        }

            #LookupListContainer-title .table, #LookupListContainer-body .table {
                margin: 0;
                border: none;
            }

        td {
            -ms-word-break: break-all;
            word-break: break-all;
        }
    </style>
    <script>
        var a = new Array();
        window.onload = function () {
            var f = setInterval("f();", 30000);
        }
        function checkbox_state() {
            $("#ListContainer-body td input[type=checkbox][oid]").each(function (e) {
                $(this).prop('checked', a[e]);
                if (a[e]) {
                    $(this).parent().parent().css("background-color", "#CCE8FF");
                }
            });
            a = [];
        }
        function f() {
            $("#ListContainer-body td input[type=checkbox][oid]").each(function () {
                a.push($(this).prop('checked'));
            });
            var order = String.format("{0} {1} ", core.View.Orderby[id].att, core.View.Orderby[id].value);
            core.View.GetListData(core.EntityName[id], JSON.stringify(core.View.FilterData[id]), order, id, core.ListData[id].Index);
            checkbox_state();
        }

        core.View.GetListData = function (etn, filterData, order, id, pagenum, pagesize) {
            $.TL_LockScreen();
            if (pagenum == undefined)
                pagenum = (core.View.PageParam[id] ? core.View.PageParam[id].pagenum : 0);
            if (pagesize == undefined)
                pagesize = (core.View.PageParam[id] ? core.View.PageParam[id].pagesize : 50);
            if (core.View.LinkEntity) {
                $.ajax({
                    type: "post",
                    url: "/Service/Data/GetN2NData.ashx",
                    async: false,
                    data: {
                        "linkentityid": core.View.LinkEntity.aid,
                        "Function": "Read",
                        "EntityM": core.View.LinkEntity.entityM,
                        "EntityA": core.View.LinkEntity.entityA,
                        "EntityB": core.View.LinkEntity.entityB,
                        //"EntityB": EntityName,
                        "filter": filterData,
                        "order": order,
                        "pagenum": pagenum,
                        "pagesize": pagesize,
                        "ViewName": core.ViewName[id]
                    },
                    dataType: "json",
                    success: function (data, textStatus) {
                        setTimeout("$.TL_unLockScreen();", 500);
                        //$.TL_unLockScreen();
                        $("#" + id + " [name=ListContainer] tbody").html(core.View.BindListItem(data, id));

                        core.View.BindListPageing(id);
                    },
                    error: Common.AjaxError
                });
            }
            else {
                $.ajax({
                    type: "post",
                    url: ((core.View.Url[id] == "" || core.View.Url[id] == undefined) ? "/Service/Data/GetListData.ashx" : core.View.Url[id]),
                    dataType: "json",
                    async: false,
                    data: { entityname: etn, order: order, pagenum: pagenum, pagesize: pagesize, filter: filterData, ViewName: core.ViewName[id] },
                    success: function (data, textStatus) {
                        setTimeout("$.TL_unLockScreen();", 500);
                        //$.TL_unLockScreen();
                        $("#" + id + " [name=ListContainer] tbody").html(core.View.BindListItem(data, id));

                        core.View.BindListPageing(id);

                        if (typeof (core.View.DoAfterView) == 'function') {
                            core.View.DoAfterView(id);
                        }

                    },
                    error: Common.AjaxError
                });
            }
        }

        core.View.SwitchView = function (src, id) {
            //core.ViewName[id] = $(src).val();
            //重新获取Field
            var UrlBase = "/Pages/DataPages/View/ViewPageAutoRefresh.aspx?entityname={0}&viewname={1}";
            window.location.href = String.format(UrlBase, EntityName, $(src).val());
        }

    </script>
</head>
<body>

    <div class="header" id="buttonheader">
        <span style="display: none" id="btn_add"><a href="#" class="btn btn-primary ng-binding" title="Create" id="add_href" onclick="core.OpenEntity(this)"><span class="glyphicon glyphicon-plus"></span>&nbsp;新建</a></span>
        <span style="display: none" id="btn_delete"><a href='#' class="btn btn-primary ng-binding" title="Delete" id="delete_href" onclick="core.SoftDelete(this);"><span class="glyphicon glyphicon-trash"></span>&nbsp;删除</a></span>
        <span style="display: none" id="btn_recoverSoftDelete"><a href='#' class="btn btn-primary ng-binding" title="recoverSoftDelete" id="recoverSoftDelete_href" onclick="core.recoverSoftDelete();"><span class="glyphicon glyphicon-retweet"></span>&nbsp;恢复</a></span>
        <span style="display: none" id="btn_assign"><a href='#' class="btn btn-primary ng-binding" title="Assign" id="assign_href" onclick="core.Assign();"><span class="glyphicon glyphicon-share"></span>&nbsp;分配</a></span>
        <div class="btn-group">
            <button class="btn btn-primary ng-binding dropdown-toggle" style="margin-right: 5px" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="glyphicon glyphicon-download"></span>
                导出 <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <li style="cursor: pointer"><a onclick="core.ExportSinglePage('ListInnerContainer')">导出当前页面</a></li>
                <li style="cursor: pointer"><a onclick="core.ExportAllPages('ListInnerContainer')">导出所有页面</a></li>
            </ul>
        </div>

    </div>
    <div id="modaldiv">
    </div>
    <div id="ListInnerContainer">
        <form id="form2" runat="server">
        </form>
    </div>
</body>
</html>


